<template>
    <div id="tmpl">
        <!--利用mui的图文表格实现-->
        <!--http://localhost:8011/getJson_war_exploded/examples/slider-table-default.html#-->
        <div id="mui-content" class="mui-content" style="background-color:#fff">
            <ul class="mui-table-view mui-grid-view">
                <li v-for="item in list"  class="mui-table-view-cell mui-media mui-col-xs-6">
                    <router-link v-bind="{to:'/goods/goodsinfo/' + item.id}" href="#">
                        <img class="mui-media-object" :src="item.img_url">
                        <div class="mui-media-body" v-text="item.title"></div>
                        <div class="desc">
                            <p>
                                <span>￥{{item.sell_price}}</span>
                                <s>￥{{item.market_price}}</s>
                            </p>
                            <p>
                                <h6 class="left">热卖中</h6>
                                <h6 class="right">剩余60件</h6>
                            </p>
                        </div>
                    </router-link>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
    import common from '../../kits/common.js';
    import {Toast} from 'mint-ui';
    export default {
        data() {
            return {
                list: [
                    // {
                    //     "id": 87,
                    //     "title": "华为荣耀1",
                    //     "add_time": "2015-7-8 15:57:11",
                    //     "zhaiyao": "华为手机哈哈哈哈哈",
                    //     "click": 0,
                    //     "img_url": "http://localhost:8011/getJson_war_exploded/images/muwu.jpg",
                    //     "sell_price": 998,
                    //     "market_price": 92499,
                    //     "stock_quantity": 620
                    // },
                    // {
                    //     "id": 88,
                    //     "title": "华为荣耀1",
                    //     "add_time": "2015-7-8 15:57:11",
                    //     "zhaiyao": "华为手机哈哈哈哈哈",
                    //     "click": 135,
                    //     "img_url": "http://localhost:8011/getJson_war_exploded/images/muwu.jpg",
                    //     "sell_price": 2195,
                    //     "market_price": 9999,
                    //     "stock_quantity": 260
                    // },
                    // {
                    //     "id": 89,
                    //     "title": "华为荣耀2",
                    //     "add_time": "2015-7-8 15:57:11",
                    //     "zhaiyao": "华为手机哈哈哈哈哈",
                    //     "click": 43,
                    //     "img_url": "http://localhost:8011/getJson_war_exploded/images/muwu.jpg",
                    //     "sell_price": 2195,
                    //     "market_price": 2999499,
                    //     "stock_quantity": 8760
                    // },
                    // {
                    //     "id": 90,
                    //     "title": "华为荣耀3",
                    //     "add_time": "2015-7-8 15:57:11",
                    //     "zhaiyao": "啦啦啦哈哈哈哈哈",
                    //     "click": 0,
                    //     "img_url": "http://localhost:8011/getJson_war_exploded/images/shuijiao.jpg",
                    //     "sell_price": 2195,
                    //     "market_price": 2499,
                    //     "stock_quantity": 460
                    // },
                    // {
                    //     "id": 91,
                    //     "title": "华为荣耀4",
                    //     "add_time": "2017-7-8 15:57:11",
                    //     "zhaiyao": "华为手机哈哈哈哈哈",
                    //     "click": 10,
                    //     "img_url": "http://localhost:8011/getJson_war_exploded/images/muwu.jpg",
                    //     "sell_price": 2195,
                    //     "market_price": 3499,
                    //     "stock_quantity": 760
                    // },
                    // {
                    //     "id": 92,
                    //     "title": "华为荣耀5",
                    //     "add_time": "2019-7-8 15:57:11",
                    //     "zhaiyao": "华为手机哈哈哈哈哈",
                    //     "click": 40,
                    //     "img_url": "http://localhost:8011/getJson_war_exploded/images/muwu.jpg",
                    //     "sell_price": 2195,
                    //     "market_price": 4499,
                    //     "stock_quantity": 120
                    // }
                ]
            }
        },
        created() {
          this.getlist();
        },
        methods: {
            getlist() {
                //获取商品列表数据
                var url = common.apidomain + '/GoodsList?pageindex=1';
                this.$http.get(url).then(function (resp) {
                    if (resp.body.status != 0) {
                        Toast(resp.body.message);
                        return;
                    }
                    //赋值操作
                    this.list = resp.body.message;
                });
            }
        }
    }
</script>

<style scoped>

    #mui-content li {
        border: 1px solid rgba(0,0,0,0.4);
        margin-left: 0px;
        padding:0px;
        margin: 0px;
        -webkit-box-shadow: 0 0 4px #000000;
        -moz-box-shadow: 0 0 4px #000000;
        box-shadow: 0 0 4px #000000;

    }

    #mui-content .mui-media-body {
        color:  #0094ff;
    }
    #mui-content .desc {
        padding: 10px;
        margin-top: 10px;
        height: 100px;
        background-color: rgba(0,0,0,0.2);
        padding: 5px;
        text-align: left;
    }

    #mui-content .desc span {
        color: red;
        margin-right: 15px;
    }
    #mui-content .desc a{
    }

    #mui-content a, #mui-content li {
        padding-left: 0px;
        margin: 0px;
    }


    #mui-content .desc .right {
        position: absolute;
        right: 10px;
        bottom: 0px;
    }
    #mui-content .desc .left{
        position: absolute;
        left: 10px;
        bottom: 0px;
    }

</style>